package com.xxxy.quartz;

import com.xxxy.dao.ExaminationPaperDao;
import com.xxxy.model.ExaminationPaper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author sjh
 * @date 2022/2/8 20:57
 */
@Service
@Slf4j
public class ExamQuartzService {

    @Autowired
    ExaminationPaperDao examinationPaperDao;

    public void start(Integer id){
        ExaminationPaper examinationPaper = examinationPaperDao.selectById(id);
        examinationPaper.setStatus(4);
        if(examinationPaperDao.updateById(examinationPaper) == 1){
            log.info("试卷"+ id + "成功开启考试");
        }
    }

    public void end(Integer id){
        ExaminationPaper examinationPaper = examinationPaperDao.selectById(id);
        examinationPaper.setStatus(5);
        if(examinationPaperDao.updateById(examinationPaper) == 1){
            log.info("试卷"+ id + "结束考试，开始审卷");
        }
    }

    public ExaminationPaper getExamById(Integer id){
        return examinationPaperDao.selectById(id);
    }
}
